package DB;

import java.sql.*;

public class DBconnection {

	public static String url = "jdbc:mysql://gz-cdb-fjqzh6rr.sql.tencentcdb.com:63771/qq";        //用于连接远程服务器
	public static String user = "root";
	public static String password = "Leagueofmysql326";
	public static Connection con = null;
	
	public void connect() {
		
		try
		{
			Class.forName("com.mysql.cj.jdbc.Driver");
			con = DriverManager.getConnection(url,user,password);
			System.out.println("成功连接数据库");
			
		}catch(ClassNotFoundException e)
		{
			e.getMessage();
		}
		catch(SQLException e)
		{
			e.getMessage();
		}
	}

	public void close()  {
		try
		{
			con.close();
			System.out.println("成功关闭数据库");
			
		}catch(SQLException e)
		{
			e.getMessage();
		}
		
	}
}